package com.dp.factory.simple_factory.controller;

import com.dp.factory.simple_factory.entity.AwardInfo;
import com.dp.factory.simple_factory.entity.ResponseResult;
import com.dp.factory.simple_factory.factory.FreeGoodsFactory;
import com.dp.factory.simple_factory.service.IFreeGoods;

/**
 * @Author: Ruomeng
 * @Date: 2024/11/26
 * @Description : design-pattern
 * 发放奖品接口
 * @Version: 1.0
 */
public class DeliverController {

    public ResponseResult awardToUser(AwardInfo awardInfo) {
        try {
            IFreeGoods freeGoods = FreeGoodsFactory.getInstance(awardInfo.getAwardTypes());
            return freeGoods.sendFreeGoods(awardInfo);
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult("201", "奖品发放失败");
        }
    }

}
